package com.two.screen.water.balance.widget.dialog

import android.app.Dialog
import android.content.Context
import android.os.Bundle
import android.view.Gravity
import android.widget.TextView
import com.two.screen.water.balance.R
import com.two.screen.water.balance.ui.App


class LoginOutDialog(context: Context) : Dialog(context, R.style.ChooseDialog) {

    private var mLoginOutDialogListener: LoginOutDialogListener? = null
    private var dialog_tv1: TextView? = null
    private var dialog_tv2: TextView? = null

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.dialog_login_out)
        this.setCanceledOnTouchOutside(false)

        val window = window
        if (window != null) {
            val attributes = window.attributes
            attributes.width = App.screenWidth
            window.attributes = attributes
            window.setGravity(Gravity.CENTER)
        }

        dialog_tv1 = findViewById(R.id.dialog_tv1)
        dialog_tv2 = findViewById(R.id.dialog_tv2)

        dialog_tv1?.setOnClickListener {
            dismiss()
        }
        dialog_tv2?.setOnClickListener {
            mLoginOutDialogListener?.onConfirm()
            dismiss()
        }
    }


    fun setLoginOutDialogListener(l: LoginOutDialogListener) {
        mLoginOutDialogListener = l
    }


    interface LoginOutDialogListener {
        fun onConfirm()
    }
}
